package com.king.juc.n7;

import java.sql.Connection;

import static com.king.juc.utils.ThreadUtil.sleep;

/**
 * DIY 连接池演示
 * @author king
 * @date 2020/12/6 22:41
 */
public class MyPoolDemo {
    public static void main(String[] args) {
        Pool pool = new Pool(2);
        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                Connection borrow = pool.borrow();
                sleep(1);
                pool.free(borrow);
            }).start();
        }
    }
}
